package com.city.itis.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;


/**
 * 爱好信息JavaBean值类
 * @author WY
 *
 */
@Entity
@Table(name = "Hobby")
public class Hobby implements Serializable
{
	private static final long serialVersionUID = 1L;
	private Integer id;		//爱好编号
	private String name;	//爱好名称
	private Set<Member> members= new HashSet<Member>(); 
	
	@Id
	@GeneratedValue
	public Integer getId() 
	{
		return id;
	}
	public void setId(Integer id) 
	{
		this.id = id;
	}
	public String getName() 
	{
		return name;
	}
	public void setName(String name) 
	{
		this.name = name;
	}
	
	/**
	* One 代表Hobby，Many代表Member ,我们需要在多的一方添加外键，如果不添加@JoinColumn(name="hobbyId")，将会生成一张t_hobby_t_member的中间表
	* 否则将会在user表中自动添加groupId字段
	* @return
	*/
	@ManyToMany(mappedBy="hobbys")
	public Set<Member> getMembers()
	{
		return members;
	}
	public void setMembers(Set<Member> members) 
	{
		this.members = members;
	}
	
	
}
